package ucm;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import model.Database_Model;

public class UCUpdateUser {

    private String[] userinfo;

    public UCUpdateUser() {
    }

    public String[] run() {
        try {
            Connection con = new Database_Model().getConnection();
            Statement stmt = con.createStatement();
            ResultSet res = stmt.executeQuery("select * from user");
            if (res.first() && !res.wasNull()) {
                res.last();
                userinfo = new String[res.getRow()];
                res.beforeFirst();
                int count = 0;
                while (res.next()) {
                    userinfo[count] = res.getString("Name");
                    System.out.println(userinfo[count]);
                    count++;
                }
            } else {
                userinfo = null;
            }
        } catch (Exception e) {
            e.printStackTrace();
            userinfo = null;
        }

        return userinfo;
    }
}
